#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<vector>
using namespace std;

class Solution {
public:
    int hammingWeight(int n) {
        int ret = 0;
        while (n)
        {
            n &= n - 1;
            ++ret;
        }
        return ret;
    }

    int hammingDistance(int x, int y) {
        int ret = 0, n = x ^ y;
        while (n)
        {
            n &= n - 1;
            ++ret;
        }
        return ret;
    }

    vector<int> countBits(int n) {
        vector<int> ret(n + 1, 0);
        for (int i = 1; i <= n; i++)
        {
            if (i % 2 == 1)    ret[i] = ret[i - 1] + 1;
            else    ret[i] = ret[i / 2];
        }
        return ret;
    }

    int singleNumber1(vector<int>& nums) {
        int ret = 0;
        for (auto x : nums)
            ret ^= x;
        return ret;
    }

    vector<int> singleNumber(vector<int>& nums) {
        int n = 0;
        for (auto x : nums)  n ^= x;

        int lowbit = n == INT_MIN ? INT_MIN : n & (-n);
        int x1 = 0, x2 = 0;
        for (auto x : nums)
        {
            if (x & lowbit)  x1 ^= x;
            else    x2 ^= x;
        }
        return { x1,x2 };
    }

};

int main()
{
    Solution s;
    vector<int> x({ 1,1,3,-2147483648});
    s.singleNumber(x);
    return 0;
}
